<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-lx-calendar"></i> 文章管理
                </el-breadcrumb-item>
                <el-breadcrumb-item>发布文章</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="form-box">
                <el-form ref="form" :model="form" label-width="80px">
                    <el-form-item label="文章标题" prop="title">
                        <el-input v-model="form.title"></el-input>
                    </el-form-item>
                    <el-form-item label="文章分类" prop="categories">
                        <el-input v-model="form.categories"></el-input>
                    </el-form-item>
                    <el-form-item label="文章标签" prop="tags">
                        <el-input v-model="form.tags"></el-input>
                    </el-form-item>
<!--                    <el-form-item label="选择特色图像" prop="tags">-->
<!--                        <el-image style="margin-left: 20px"-->
<!--                                  src="https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg">-->
<!--                            <div slot="placeholder" class="image-slot">-->
<!--                                加载中<span class="dot">...</span>-->
<!--                            </div>-->
<!--                        </el-image>-->
<!--                    </el-form-item>-->

                    <el-form-item label="url" prop="tags">
                        <el-input v-model="form.articlePicUrl"></el-input>
                    </el-form-item>

                    <el-form-item label="文本框" prop="content">
                        <mavon-editor v-model="form.content" ref="md" @imgAdd="$imgAdd" @change="change" style="min-height: 600px"/>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="onSubmit">表单提交</el-button>
                        <el-button>取消</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </div>
    </div>
</template>

<script>
    import { mavonEditor } from 'mavon-editor'
    import 'mavon-editor/dist/css/index.css'
export default {
    name: 'baseform',
    components:{mavonEditor},
    data() {
        return {
            form: {
                title: '',
                categories: '',
                tags: '',
                context: '',
                articlePicUrl:''
            }
        };
    },
    methods: {
        onSubmit() {
            const _this=this
            this.$axios.post("http://39.106.115.234:8083/article/publish",this.form,{
                headers:{
                    "Authorization":localStorage.getItem("token")
                }
            }).then(res=>{
                // console.log(res.data)
                _this.$message.success(res.data.message)
                _this.$router.push("/table")
            })
            // this.$message.success('提交成功！');
        }
    }
};
</script>
